﻿<!--#include virtual="/2010admin/Check_Priv.asp"-->
<%
'景点图片操作文件
Dim IP_ID			
Dim Spot_ID			
Dim IP_Title		
Dim IP_Path		
Dim IP_Order		
Dim IP_IsCover		

Dim IP_Path_Old

Add_Msg = "景点图片增加成功！"
Edit_Msg= "景点图片息修改成功！"
Del_Msg = "景点图片删除成功！"

Goto_URL = "Spot_Pic_Query.asp?Spot_ID="&Spot_ID

Sub News_Pic_Add()	

	Goto_URL = "Spot_Pic_Query.asp?Spot_ID="&Spot_ID
	
	For i = 0 To UBound(Split(Pic_Path,"|"))

		sPic_Path = Split(Pic_Path,"|")(i)
		sPic_Name = Split(Pic_Name,"|")(i)
		sIsCover  = Split(IsCover,"|")(i)

		sql =   "INSERT INTO Spot_Pic( "&_
				"Spot_ID"&_
				",IP_Title" &_		
				",IP_Path" &_
				",IP_IsCover" &_ 
								
				") VALUES( " &_
				Spot_ID&_
				",'" &sPic_Name& "'" &_
				",'" &sPic_Path& "'" &_
				","&sIsCover&_
				")" 
		conn.execute(sql)
	Next

	If Pic_Path<>"" Then 
		Pic_Array = Split(Pic_Path,"|")
		For Y=0 To UBound(Pic_Array)
			Call make_small_pic(Pic_Path,C_News_Pic_Width,C_News_Pic_Height)
		Next 
	End If 
	AlertBox Add_Msg,Goto_URL

End Sub

Sub News_Pic_Edit()	
	
	Call Check_IsNumeric_Msg(Spot_ID,"景点ID")
	Call Check_IsNumeric_Msg(IP_ID,"景点图片ID")

	Goto_URL = "Spot_Pic_Query.asp?Spot_ID="&Spot_ID


	If Pic_Path="" Then

		sql = "UPDATE Spot_Pic Set " &_
		  " IP_Title   = '" & IP_Title & "'" &_
		  ",IP_IsCover	= '" & IP_IsCover & "'" &_
		  " WHERE IP_ID= "&IP_ID

	Else
		'同时删除大图和小图
		delete_flag=delete_file(IP_Path_Old)

		sql = "UPDATE Spot_Pic Set " &_
		  " IP_Title   = '" & IP_Title & "'" &_
		  ",IP_IsCover	= '" & IP_IsCover & "'" &_
		  ",IP_Path	= '" & Pic_Path & "'" &_
		  " WHERE IP_ID   = "&IP_ID

	End If
	
    conn.execute(sql)

	If Pic_Path<>"" Then 
		Call make_small_pic(Pic_Path,C_News_Pic_Width,C_News_Pic_Height)
	End If


	AlertBox Edit_Msg,Goto_URL
	
	
End Sub

Function News_Pic_Del()

	Spot_ID = requery("Spot_ID")

	IP_ID = reform("OP_ID")
	Call Check_IsNumeric_Msg(Spot_ID,"景点ID")

	Goto_URL = "Spot_Pic_Query.asp?Spot_ID="&Spot_ID


	sql = "SELECT IP_Path FROM Spot_Pic WHERE IP_ID IN( " &IP_ID &")"

	Array_List = GetRsRows(Sql)
	'同时删除大图和小图

	If IsArray(Array_List) Then 
		For i=0 To UBound(Array_List,2)
			IP_Path = Array_List(0,0)
			delete_flag=delete_file(IP_Path)

		Next 
	End If



	Sql = "DELETE FROM Spot_Pic WHERE IP_ID IN( " &IP_ID &")"

	conn.execute(sql)

	AlertBox Del_Msg,Goto_URL

End Function 



Sub Get_News_Pic()

	IP_ID = requery("IP_ID")	
	Spot_ID = requery("Spot_ID")	

	Call Check_IsNumeric_Msg(IP_ID,"图片ID")
	Call Check_IsNumeric_Msg(Spot_ID,"景点ID")


	sql = "SELECT * FROM Spot_Pic WHERE IP_ID = " &IP_ID

	Set rs = conn.execute(sql)
	
	If Not rs.eof Then

		IP_Title = rs("IP_Title")
		IP_Path = rs("IP_Path")

		IP_Order	= rs("IP_Order")
		IP_IsCover	= rs("IP_IsCover")

	End If
	

End Sub 

%>